#include<bits/stdc++.h>
using namespace std;
const int N=200002;
long long a[N];
bool hash[1000001];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    for(int z=0;z<t;z++){
        int n;
        cin>>n;
        long long ans;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            if(hash[a[i]]!=0)
                ans+=a[i];
            hash[a[i]]=1;
        }
        cout<<ans<<endl;
    }
    return 0;
}
